/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!50503 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

CREATE DATABASE IF NOT EXISTS `{{= d.name.toLowerCase().replace('-', '_') }}` /*!40100 DEFAULT CHARACTER SET utf8mb4 */;
USE `{{= d.name.toLowerCase().replace('-', '_') }}`;

CREATE TABLE IF NOT EXISTS `{{= d.name.toLowerCase().replace('-', '_') }}_ip_whitelist` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `app_id` varchar(20) NOT NULL,
  `ip` varchar(20) NOT NULL,
  `create_at` bigint(20) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `appid` (`app_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='IP白名单';

CREATE TABLE IF NOT EXISTS `{{= d.name.toLowerCase().replace('-', '_') }}_key_app` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `app_id` varchar(20) NOT NULL COMMENT 'app_id',
  `app_secret` varchar(50) NOT NULL COMMENT '签名的key',
  `name` varchar(50) DEFAULT NULL COMMENT '应用名称',
  `status` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '是否有效,1-有效,0-无效',
  `create_at` bigint(20) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `app_id` (`app_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='做签名校验的app列表';

/*!40103 SET TIME_ZONE=IFNULL(@OLD_TIME_ZONE, 'system') */;
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1) */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40111 SET SQL_NOTES=IFNULL(@OLD_SQL_NOTES, 1) */;
